import { Record } from "../types/record";
import { SERVER_HOST } from "./host"

export const fetchRecords = async(handler:React.Dispatch<React.SetStateAction<Record[]>>)=>{
    const resp = await fetch(`${SERVER_HOST}/api/record`);
    const data = await resp.json()
    if(data.error){
        throw new Error(data.error)
    }
    handler(data.data ?? [])
}